﻿using System;

namespace YJKRevitBase.YJKElement
{
	public class PaireElement<T> where T : class
	{
		public PaireElement(T inputLeftValue, T inputRightValue)
		{
			this.LeftValue = inputLeftValue;
			this.RightValue = inputRightValue;
		}

		public T LeftValue
		{
			get
			{
				return this.m_leftValue;
			}
			private set
			{
				this.m_leftValue = value;
			}
		}

		public T RightValue
		{
			get
			{
				return this.m_rightValue;
			}
			private set
			{
				this.m_rightValue = value;
			}
		}

		public override bool Equals(object obj)
		{
			if (obj != null && obj is PaireElement<T>)
			{
				PaireElement<T> paireElement = obj as PaireElement<T>;
				return (paireElement.LeftValue == this.LeftValue && paireElement.RightValue == this.RightValue) || (paireElement.RightValue == this.LeftValue && paireElement.LeftValue == this.RightValue);
			}
			return false;
		}

		public override int GetHashCode()
		{
            return System.Math.Min(this.LeftValue.GetHashCode(), this.RightValue.GetHashCode()) + System.Math.Max(this.LeftValue.GetHashCode(), this.RightValue.GetHashCode());
		}

		private T m_leftValue;

		private T m_rightValue;
	}
}
